<?php

App::uses('AppRule', 'Lib');

class RequireEnd extends AppRule {

    public function apply(Leave $leave) {
        $ret  = true;
        $data = $leave->data['Leave'];
        
        if (empty($data['end']) || !preg_match('/^\d{4}-\d{2}-\d{2}$/', $data['end'])) {
            $ret = false;
            $this->setError('End date is required.');
        }
        
        return $ret;
    }

}

?>